package com.atguigu.juc;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(7);
        for (int i = 1; i <=7; i++) {
            int finalI = i;
            new Thread(() -> {
                        System.out.println(Thread.currentThread().getName()+ finalI+"离开");
                        countDownLatch.countDown();
                    },String.valueOf(i)).start();
                }

        countDownLatch.await();
        System.out.println("结束");

    }
}
